set more off

use "NES2004 (raw).dta"

**********Dependent Variable: Vote Choice****************
gen vote = . 
replace vote = 1 if V045026 == 3
replace vote = 0 if V045026 == 1
label def vot 1 "Bush" 0 "Kerry"
label values vote vot
label var vote "Vote Choice"

************Information**********
	foreach var in V045162 V045163 V045164 V045165 V045089 V045090 { 
		codebook `var' 
		}
		
		label def corre 1 "Correct" 0 "Incorrect/No Guess"
		recode V045162 (1=1) (5=0) (8=0), gen(hastert)
		recode V045163 (1=1) (5=0) (8=0), gen(cheney)
		recode V045164 (1=1) (5=0) (8=0), gen(blair) 
		recode V045165 (1=1) (5=0) (8=0), gen(rein) 
		recode V045089 (1=0) (5=1) (8=0), gen(house)
		recode V045090 (1=0) (5=1) (8=0), gen(senate)

		foreach var in hastert cheney blair rein house senate {
			label values `var' corre
			tab `var'
			}
		egen knowl = rowtotal(hastert cheney blair rein house senate), missing
		tab knowl
		summ knowl, detail



**********Main Ind. Variable: Policy Attitude, Importance, Proximity****************
***Defense***
*own attitude, candidate placement*
	rename V043142 defense2004
	rename V043144 bushdefense2004
	rename V043145 kerrydefense2004
	mvdecode defense2004 bushdefense2004 kerrydefense2004 , mv(8 = .\ 9 = . \ 80 = . \ 88 = . )


*Proximity
	*City Block: Sample
		summarize bushdefense2004 kerrydefense2004 
		*bush  5.7496988 
		*kerry 3.625801

		gen defense2004prox = abs(defense2004 - 3.625801) - abs(defense2004 - 5.746988)

	*City Block: informed
		summarize bushdefense2004 kerrydefense2004 if knowl >=4 & knowl <= 6
		*bush  6.041002
		*kerry  3.318396
		gen defense2004prox_info = abs(defense2004 - 3.318396) - abs(defense2004 - 6.041002)
		
	*City block: Self
		gen defense2004prox_self = abs(defense2004 - kerrydefense2004) - abs(defense2004 - bushdefense2004)
	
	*Euclidean
		gen defense2004prox_euclid1 = [(defense2004 - 3.625801)*(defense2004 - 3.625801)] - [(defense2004 - 5.746988)*(defense2004 - 5.746988)]
		gen defense2004prox_euclid2 = [(defense2004 - 3.318396)*(defense2004 - 3.318396)] - [(defense2004 - 6.041002)*(defense2004 - 6.041002)]
		gen defense2004prox_euclid3 = [(defense2004 - kerrydefense2004)*(defense2004 - kerrydefense2004)] - [(defense2004 - bushdefense2004)*(defense2004 - bushdefense2004)]
		
		summ defense2004prox defense2004prox_info defense2004prox_self defense2004prox_euclid1 defense2004prox_euclid2 defense2004prox_euclid3
		
*attitude strength*
gen defense2004ext = .
replace defense2004ext = 1 if defense2004 == 4
replace defense2004ext = 2 if defense2004 == 3
replace defense2004ext = 2 if defense2004 == 5
replace defense2004ext = 3 if defense2004 == 2
replace defense2004ext = 3 if defense2004 == 6
replace defense2004ext = 4 if defense2004 == 1
replace defense2004ext = 4 if defense2004 == 7
label var defense2004ext "Defense: Extremity"

gen defense2004imp = . 
replace defense2004imp = 1 if V043143 == 5
replace defense2004imp = 2 if V043143 == 4
replace defense2004imp = 3 if V043143 == 3
replace defense2004imp = 4 if V043143 == 2
replace defense2004imp = 5 if V043143 == 1
label def imp 1 "Not at all Imp" 5 "Extremely Imp"
label values defense2004imp imp


*standardized*
foreach var in defense2004prox defense2004prox_info defense2004prox_self defense2004prox_euclid1 defense2004prox_euclid2 defense2004prox_euclid3 defense2004ext defense2004imp {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	

	label var defense2004prox01 "Defense:Prox"
	label var defense2004imp01 "Defense:Imp"

***spend & services***
*own attitude, candidate placement*
	gen spend2004 = . 
	replace spend2004 = 1 if V043136 == 7
	replace spend2004 = 2 if V043136 == 6
	replace spend2004 = 3 if V043136 == 5
	replace spend2004 = 4 if V043136 == 4
	replace spend2004 = 5 if V043136 == 3
	replace spend2004 = 6 if V043136 == 2
	replace spend2004 = 7 if V043136 == 1

	gen bushspend2004 = . 
	replace bushspend2004 = 1 if V043138 == 7
	replace bushspend2004 = 2 if V043138 == 6
	replace bushspend2004 = 3 if V043138 == 5
	replace bushspend2004 = 4 if V043138 == 4
	replace bushspend2004 = 5 if V043138 == 3
	replace bushspend2004 = 6 if V043138 == 2
	replace bushspend2004 = 7 if V043138 == 1

	gen kerryspend2004 = . 
	replace kerryspend2004 = 1 if V043139 == 7
	replace kerryspend2004 = 2 if V043139 == 6
	replace kerryspend2004 = 3 if V043139 == 5
	replace kerryspend2004 = 4 if V043139 == 4
	replace kerryspend2004 = 5 if V043139 == 3
	replace kerryspend2004 = 6 if V043139 == 2
	replace kerryspend2004 = 7 if V043139 == 1

	label def spend 1 "More Services" 7 "More Services"
	label values spend2004 spend
	label values bushspend2004 spend
	label values kerryspend2004 spend

*proximity*
	*City Block: Sample
		summarize *spend2004
		*bush  4.568523
		*kerry  2.982092

		gen spend2004prox = abs(spend2004 - 2.982092) - abs(spend2004 - 4.568523)

	*City Block: Informed
		summarize *spend2004 if knowl >=4 & knowl <= 6
		*bush    4.765808
		*kerry   2.539024
		gen spend2004prox_info = abs(spend2004 -  2.539024) - abs(spend2004 - 4.765808)
	
	*city Block: Self
		gen spend2004prox_self = abs(spend2004 -  kerryspend2004) - abs(spend2004 - bushspend2004)

	*Euclidean
		gen spend2004prox_euclid1 = [ (spend2004 - 2.982092)*(spend2004 - 2.982092) ] - [ (spend2004 - 4.568523)*(spend2004 - 4.568523)  ] 
		gen spend2004prox_euclid2 = [(spend2004 -  2.539024)*(spend2004 -  2.539024)  ] - [ (spend2004 - 4.765808)*(spend2004 - 4.765808) ] 
		gen spend2004prox_euclid3 = [(spend2004 -  kerryspend2004)*(spend2004 -  kerryspend2004)  ] - [ (spend2004 - bushspend2004)*(spend2004 - bushspend2004)  ] 

		summ spend2004prox spend2004prox_info spend2004prox_self spend2004prox_euclid1 spend2004prox_euclid2 spend2004prox_euclid3
		
		
*attitude strength*
	gen spend2004ext = .
	replace spend2004ext =  1  if spend2004 == 4
	replace spend2004ext =  2  if spend2004 == 3
	replace spend2004ext =  2  if spend2004 == 5
	replace spend2004ext =  3  if spend2004 == 2
	replace spend2004ext =  3  if spend2004 == 6
	replace spend2004ext =  4  if spend2004 == 1
	replace spend2004ext =  4  if spend2004 == 7

	gen spend2004imp = .
	replace spend2004imp = 1 if V043137 == 5
	replace spend2004imp = 2 if V043137 == 4
	replace spend2004imp = 3 if V043137 == 3
	replace spend2004imp = 4 if V043137 == 2
	replace spend2004imp = 5 if V043137 == 1
	label values spend2004imp imp



*standardized*
foreach var in spend2004prox spend2004prox_info spend2004prox_self spend2004prox_euclid1 spend2004prox_euclid2 spend2004prox_euclid3 spend2004ext spend2004imp {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
	
	label var spend2004prox01 "Spend:Prox"
	label var spend2004imp01 "Spend:Imp"

***Jobs***
*own attitude, candidate placement*
	rename V043152 jobs2004
	rename V043154  bushjobs2004
	rename V043155 kerryjobs2004
	mvdecode *jobs2004, mv(8 = . \ 9 = . \ 80 = . \ 88 = .)

*proximity*
	*City block: sample
		summ *jobs2004
		*bush: 5.2
		*kerry: 3.197471

		gen jobs2004prox = abs(jobs2004 - 3.197471) - abs(jobs2004 - 5.2)

	*City block: informed
		summ *jobs2004 if knowl >=4 & knowl <= 6
		*bush:   5.546099 
		*kerry: 2.900744
		gen jobs2004prox_info = abs(jobs2004 - 2.900744) - abs(jobs2004 -   5.546099 )
	
	*city block: self
		gen jobs2004prox_self = abs(jobs2004 - kerryjobs2004) - abs(jobs2004 -   bushjobs2004 )
		
	*euclidean
		gen jobs2004prox_euclid1 = [(jobs2004 - 3.197471)*(jobs2004 - 3.197471)  ] - [ (jobs2004 - 5.2)*(jobs2004 - 5.2) ] 
		gen jobs2004prox_euclid2 = [ (jobs2004 - 2.900744) *(jobs2004 - 2.900744)  ] - [(jobs2004 -   5.546099 )*(jobs2004 -   5.546099 )  ] 
		gen jobs2004prox_euclid3 = [ (jobs2004 - kerryjobs2004)*(jobs2004 - kerryjobs2004) ] - [ (jobs2004 -   bushjobs2004 )*(jobs2004 -   bushjobs2004 ) ] 

		summ jobs2004prox jobs2004prox_info jobs2004prox_self jobs2004prox_euclid1 jobs2004prox_euclid2 jobs2004prox_euclid3
		
		
		

*attitude strength*
	gen jobs2004ext = . 
	replace jobs2004ext = 1 if jobs2004 == 4
	replace jobs2004ext = 2 if jobs2004 == 3
	replace jobs2004ext = 2 if jobs2004 == 5
	replace jobs2004ext = 3 if jobs2004 == 2
	replace jobs2004ext = 3 if jobs2004 == 6
	replace jobs2004ext = 4 if jobs2004 == 1
	replace jobs2004ext = 4 if jobs2004 == 7

	gen jobs2004imp = . 
	replace jobs2004imp = 1 if V043153 == 5
	replace jobs2004imp = 2 if V043153 == 4
	replace jobs2004imp = 3 if V043153 == 3
	replace jobs2004imp = 4 if V043153 == 2
	replace jobs2004imp = 5 if V043153 == 1
	label values jobs2004imp imp


*standardized*
	foreach var in jobs2004prox jobs2004prox_info jobs2004prox_self jobs2004prox_euclid1 jobs2004prox_euclid2 jobs2004prox_euclid3 jobs2004ext jobs2004imp {
			qui sum `var'
			gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
		}
		
		
	label var jobs2004prox01 "Jobs:Prox"
	label var jobs2004imp01 "Jobs:Imp"
	
***Aid to Blacks***
*own attitude, candidate placement*
	rename V043158 blackaid2004
	rename V043160 bushblackaid2004
	rename V043161 kerryblackaid2004
	mvdecode *blackaid2004,  mv(8 = . \ 9 = . \ 80 = . \ 88 = . \ 89 = . )

*proximity*
	*city block: sample
		summarize *blackaid2004
		*kerry : 3.325532
		*bush : 4.955045

		gen blackaid2004prox = abs(blackaid2004 - 3.325532) - abs(blackaid2004 - 4.955045)

	*city block: info
		summarize *blackaid2004 if knowl >=4 & knowl <= 6
		*kerry :  2.973046
		*bush :  5.2375
		gen blackaid2004prox_info = abs(blackaid2004 -  2.973046) - abs(blackaid2004 -  5.2375)

	*city block: self
		gen blackaid2004prox_self = abs(blackaid2004 -  kerryblackaid2004) - abs(blackaid2004 -  bushblackaid2004)
	
	*euclid
		gen blackaid2004prox_euclid1 =  [(blackaid2004 - 3.325532)*(blackaid2004 - 3.325532)   ] - [ (blackaid2004 - 4.955045)*(blackaid2004 - 4.955045) ] 
		gen blackaid2004prox_euclid2 =  [(blackaid2004 -  2.973046)*(blackaid2004 -  2.973046)  ] - [ (blackaid2004 -  5.2375)*(blackaid2004 -  5.2375) ] 
		gen blackaid2004prox_euclid3 =  [ (blackaid2004 -  kerryblackaid2004)*(blackaid2004 -  kerryblackaid2004)  ] - [ (blackaid2004 -  bushblackaid2004)*(blackaid2004 -  bushblackaid2004) ] 
	
		summ blackaid2004prox blackaid2004prox_info blackaid2004prox_self blackaid2004prox_euclid1 blackaid2004prox_euclid2 blackaid2004prox_euclid3
		

*attitude strength*
	gen blackaid2004ext =  .
	replace blackaid2004ext = 1 if blackaid2004 == 4
	replace blackaid2004ext = 2 if blackaid2004 == 3
	replace blackaid2004ext = 2 if blackaid2004 == 5
	replace blackaid2004ext = 3 if blackaid2004 == 2
	replace blackaid2004ext = 3 if blackaid2004 == 6
	replace blackaid2004ext = 4 if blackaid2004 == 1
	replace blackaid2004ext = 4 if blackaid2004 == 7

	gen blackaid2004imp = . 
	replace blackaid2004imp = 1 if V043159 == 5
	replace blackaid2004imp = 2 if V043159 == 4
	replace blackaid2004imp = 3 if V043159 == 3
	replace blackaid2004imp = 4 if V043159 == 2
	replace blackaid2004imp = 5 if V043159 == 1
	label values blackaid2004imp imp



*standardized*
	foreach var in blackaid2004prox blackaid2004prox_info blackaid2004prox_self blackaid2004prox_euclid1 blackaid2004prox_euclid2 blackaid2004prox_euclid3 blackaid2004ext blackaid2004imp {
			qui sum `var'
			gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
		}
		
		
	label var blackaid2004prox01 "Aid Blacks: Prox"
	label var blackaid2004imp01 "Aid Blacks: Imp"

***Environment vs. Jobs***
	*own attitude, candidate placement*
	rename V043182  envirojobs2004 
	rename V043184 bushenvirojobs2004
	rename V043185 kerryenvirojobs2004
	mvdecode envirojobs2004 bushenvirojobs2004 kerryenvirojobs2004,  mv(8 = . \ 9 = . \ 80 = . \ 88 = . \ 89 = . )


*proximity*
	*City Block: sample
	summarize *envirojobs2004
	*bush: 4.294534
	*kerry: 4.187375

	gen envirojobs2004prox = abs(envirojobs2004 - 4.187375) - abs(envirojobs2004 - 4.294534)

	*city block: informed
		summarize *envirojobs2004 if knowl >=4 & knowl <=6
		*bush: 4.358442  
		*kerry:  4.26087

		gen envirojobs2004prox_info = abs(envirojobs2004 -  4.26087) - abs(envirojobs2004 - 4.358442  )

	
	*city block: self
		gen envirojobs2004prox_self = abs(envirojobs2004 -  kerryenvirojobs2004) - abs(envirojobs2004 - bushenvirojobs2004  )
	
	*euclid
		gen envirojobs2004prox_euclid1 = [(envirojobs2004 - 4.187375)*(envirojobs2004 - 4.187375)] - [(envirojobs2004 - 4.294534)*(envirojobs2004 - 4.294534)   ] 
		gen envirojobs2004prox_euclid2 = [(envirojobs2004 -  4.26087)*(envirojobs2004 -  4.26087)] - [(envirojobs2004 - 4.358442  )*(envirojobs2004 - 4.358442)] 
		gen envirojobs2004prox_euclid3 = [(envirojobs2004 -  kerryenvirojobs2004)*(envirojobs2004 -  kerryenvirojobs2004)] - [(envirojobs2004 - bushenvirojobs2004  )*(envirojobs2004 - bushenvirojobs2004  )   ] 
	
	summ envirojobs2004prox envirojobs2004prox_info envirojobs2004prox_self envirojobs2004prox_euclid1 envirojobs2004prox_euclid2 envirojobs2004prox_euclid3

*attitude strength*
	gen envirojobs2004ext = . 
	replace envirojobs2004ext = 1 if envirojobs2004 == 4
	replace envirojobs2004ext = 2 if envirojobs2004 == 3
	replace envirojobs2004ext = 2 if envirojobs2004 == 5
	replace envirojobs2004ext = 3 if envirojobs2004 == 2
	replace envirojobs2004ext = 3 if envirojobs2004 == 6
	replace envirojobs2004ext = 4 if envirojobs2004 == 1
	replace envirojobs2004ext = 4 if envirojobs2004 == 7

	gen envirojobs2004imp = .
	replace envirojobs2004imp = 1 if V043183 == 5
	replace envirojobs2004imp = 2 if V043183 == 4
	replace envirojobs2004imp = 3 if V043183 == 3
	replace envirojobs2004imp = 4 if V043183 == 2
	replace envirojobs2004imp = 5 if V043183 == 1
	label values envirojobs2004imp imp

*standardized*
	foreach var in envirojobs2004prox envirojobs2004prox_info envirojobs2004prox_self envirojobs2004prox_euclid1 envirojobs2004prox_euclid2 envirojobs2004prox_euclid3 envirojobs2004ext envirojobs2004imp {
			qui sum `var'
			gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
		}

		label var envirojobs2004prox01 "Enviro:Prox"
		label var envirojobs2004imp01 "Enviro:Imp"


***Gun Restrictions***
	*own attitude, candidate placement*
	rename V043189 guns2004
	rename V043192 bushguns2004
	rename V043194 kerryguns2004 
	mvdecode guns2004 bushguns2004 kerryguns2004, mv(8 = . )

*proximity*
	*city Block: Sample
		summarize *guns2004
		*kerry: 2.7311
		*bush: 2.633142

		gen guns2004prox = abs(guns2004 - 2.7311) - abs(guns2004 - 2.633142)
		**note: bush is held to be the MORE LIBERAL CANDIDATE**
		**this means, that POSITIVE scores indicate greater proximity to KERRY than to bush*
		**to fix this, the two were reversed; guns2004prox1 is the used measure*
		
		gen guns2004prox1 = abs(guns2004 - 2.633142) - abs(guns2004 - 2.7311)

	*City block: Informed
		summarize *guns2004 if knowl >=4 & knowl <= 6
		*kerry:   2.885086 
		*bush: 2.728643 

		gen guns2004prox_info = abs(guns2004 - 2.728643 ) - abs(guns2004 -   2.885086)
	
	*City Block: Self
		gen guns2004prox_self = abs(guns2004 - kerryguns2004 ) - abs(guns2004 -   bushguns2004)

		
	*Euclidean
		gen guns2004prox_euclid1 =  [(guns2004 - 2.633142)*(guns2004 - 2.633142)  ] - [(guns2004 - 2.7311)*(guns2004 - 2.7311) ] 
		gen guns2004prox_euclid2 =  [(guns2004 - 2.728643 ) *(guns2004 - 2.728643) ] - [ (guns2004 -   2.885086)*(guns2004 -   2.885086)  ] 
		gen guns2004prox_euclid3 =  [(guns2004 - kerryguns2004 )*(guns2004 - kerryguns2004 )] - [(guns2004 -   bushguns2004)*(guns2004 -   bushguns2004)] 
	
	summ guns2004prox guns2004prox1 guns2004prox_info guns2004prox_self guns2004prox_euclid1 guns2004prox_euclid2 guns2004prox_euclid3
	
	
*attitude strength*
	gen guns2004ext = .
	replace guns2004ext = 1 if guns2004 == 3
	replace guns2004ext = 2 if guns2004 == 2
	replace guns2004ext = 2 if guns2004 == 4
	replace guns2004ext = 3 if guns2004 == 1
	replace guns2004ext = 3 if guns2004 == 5

	gen guns2004imp = . 
	replace guns2004imp = 1 if V043190 == 5
	replace guns2004imp = 2 if V043190 == 4
	replace guns2004imp = 3 if V043190 == 3
	replace guns2004imp = 4 if V043190 == 2
	replace guns2004imp = 5 if V043190 == 1
	label values guns2004imp imp

*standardized*
foreach var in guns2004prox1 guns2004prox_info guns2004prox_self guns2004prox_euclid1 guns2004prox_euclid2 guns2004prox_euclid3 guns2004ext guns2004imp {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
		label var guns2004prox101 "Guns:Prox"
		label var guns2004imp01 "Guns:Imp"
	
	
	

***Women: Equal Role***
	*own attitude, candidate placement*
	rename V043196 womenrole2004 
	rename V043198 bushwomenrole2004
	rename V043199 kerrywomenrole2004
	mvdecode womenrole2004 bushwomenrole2004 kerrywomenrole2004, mv(8 = . \ 9 = . \ 80 = . \ 88 = . )

*proximity*
	*city block: sample
		summ *womenrole2004
		*bush: 3.546919
		*kerry: 2.60142

		gen womenrole2004prox = abs(womenrole2004 - 2.60142) - abs(womenrole2004 - 3.546919)

	*city block: info
		summ *womenrole2004 if knowl >=4 & knowl <= 6
		*bush:  3.508393
		*kerry: 2.260309 

		gen womenrole2004prox_info = abs(womenrole2004 - 2.260309 ) - abs(womenrole2004 -  3.508393)

	*city block: sample
		gen womenrole2004prox_self = abs(womenrole2004 - kerrywomenrole2004 ) - abs(womenrole2004 -  bushwomenrole2004)
		
	*euclidean
		gen womenrole2004prox_euclid1 = [(womenrole2004 - 2.60142)*(womenrole2004 - 2.60142)] - [(womenrole2004 - 3.546919)*(womenrole2004 - 3.546919)] 
		gen womenrole2004prox_euclid2 = [(womenrole2004 - 2.260309 )*(womenrole2004 - 2.260309 )] - [(womenrole2004 -  3.508393)*(womenrole2004 -  3.508393)] 
		gen womenrole2004prox_euclid3 = [(womenrole2004 - kerrywomenrole2004 )*(womenrole2004 - kerrywomenrole2004 )] - [(womenrole2004 -  bushwomenrole2004)*(womenrole2004 -  bushwomenrole2004)] 
	
	summ womenrole2004prox womenrole2004prox_info womenrole2004prox_self womenrole2004prox_euclid1 womenrole2004prox_euclid2 womenrole2004prox_euclid3
		
				
*attitude strength*
	gen womenrole2004ext =  .
	replace womenrole2004ext = 1 if womenrole2004 == 4
	replace womenrole2004ext = 2 if womenrole2004 == 3
	replace womenrole2004ext = 2 if womenrole2004 == 5
	replace womenrole2004ext = 3 if womenrole2004 == 2
	replace womenrole2004ext = 3 if womenrole2004 == 6
	replace womenrole2004ext = 4 if womenrole2004 == 1
	replace womenrole2004ext = 4 if womenrole2004 == 7

	gen womenrole2004imp = . 
	replace womenrole2004imp = 1 if V043197 == 5
	replace womenrole2004imp = 2 if V043197 == 4
	replace womenrole2004imp = 3 if V043197 == 3
	replace womenrole2004imp = 4 if V043197 == 2
	replace womenrole2004imp = 5 if V043197 == 1
	label values womenrole2004imp imp

*standardized*


	foreach var in womenrole2004prox womenrole2004prox_info womenrole2004prox_self womenrole2004prox_euclid1 womenrole2004prox_euclid2 womenrole2004prox_euclid3 womenrole2004ext womenrole2004imp {
			qui sum `var'
			gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
		}
		

		label var womenrole2004prox01 "Women:Prox"
		label var womenrole2004imp01 "Women:Imp"
		


**********Control Variables****************
*PID*
rename V043116 pid
mvdecode pid, mv(7 = . \ 8 = . \ 9 = .)
label var pid "PID"
summarize pid
gen pid01 = (pid - `r(min)') / (`r(max)'-`r(min)')
label var pid01 "PID"

*Ideology*

gen ideology = V043085
mvdecode ideology, mv(89 = . \ 80 = . \ 88 = .) 
label var ideology "Ideology"
summarize ideology 
gen ideology01 = (ideology - `r(min)') / (`r(max)'-`r(min)')
label var ideology01 "Ideology"

gen ideology2 = V043085
recode ideology2 (0 = 8) (9 = 8)
label var ideology2 "Ideology (Full)"
label def ideo1 8 "Haven't Thought Much/DK/NA" 1 "Ext. Liberal"  7 "Ext. Conservative" 4 "Moderate"
label values ideology2 ideo1


recode V043085 (1=1) (2=1) (3=1) (4=2) (5=3) (6=3) (7=3) ///
	(80=4) (88=4) (89=4), gen(ideol)
	
	label var ideol "Ideology"
	label def id 1 "Liberal" 2 "Moderate" 3 "Conservative" 4 "Haven't Thought/DK/Ref"
	label values ideol id

*Race
gen race = . 
replace race = 0 if V043299 >= 45 & V043299 <= 50
replace race = 1 if V043299 >=10 & V043299 <= 40
replace race = 1 if V043299 == 70
label var race "Race" 
label def rac 1 "Non-White" 0 "White"
label values race rac

gen hispanic = . 
replace hispanic = 1 if V043305 == 1
replace hispanic = 0 if V043305 == 5
label def his 1 "Hispanic" 0 "Non-Hispanic" 
label values hispanic his


*Gender*
gen gender = . 
replace gender = 1 if V041109a == 2
replace gender = 0 if V041109a == 1
label var gender "Gender" 
label def gen 1 "Female" 0 "Male"
label values gender gen


*Age*
rename V043250 age
mvdecode age, mv(00 = .)
summarize age
gen age01 = (age - `r(min)') / (`r(max)'-`r(min)')
label var age01 "Age"

*Income*
rename V043293x famincome
rename V043294 income
mvdecode famincome income, mv(88 = . \ 89 = .)

foreach var in income famincome {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')

	}
	
label var famincome "Family Income"
label var income "Own Income"
label var income01 "Own Income"
label var famincome01 "Family Income"

egen income_pct = cut(income), group(10) label
gen income_miss = . 
replace income_miss = 1 if income == .
gen income_pct1 = income_pct 
replace income_pct1 = 10 if income_miss == 1 & income_pct1 == . 
label def inc_mis1 10 "Missing Income"
label values income_pct1 inc_mis1


egen famincome_pct = cut(famincome), group(10) label
gen famincome_miss = .
replace famincome_miss = 1 if famincome == . 
replace famincome_miss = 0 if famincome !=.

gen famincome_pct1 = famincome_pct 
replace famincome_pct1 = 10 if famincome_miss == 1 & famincome_pct1 == .
label def inc_mis2 10 "Missing Income" 
label values famincome_pct1 inc_mis2

*Education*
gen educ = . 
replace educ = 1 if V043254 == 0
replace educ = 1 if V043254 == 1
replace educ = 1 if V043254 == 2
replace educ = 2 if V043254 == 3
replace educ = 3 if V043254 == 4
replace educ = 3 if V043254 == 5
replace educ = 4 if V043254 == 6
replace educ = 4 if V043254 == 7
label var educ "Education" 
label def ed 1 "< HS" 2 "HS" 3 "Some College" 4 "College+" 
label values educ ed

summarize educ
gen educ01 = (educ - `r(min)') / (`r(max)'-`r(min)')
label var educ01 "Education"


*Econ: Retrospective*
gen econ2004 = .
replace econ2004 = 1 if V043098 == 5
replace econ2004 = 2 if V043098 == 4
replace econ2004 = 3 if V043098 == 3
replace econ2004 = 4 if V043098 == 2
replace econ2004 = 5 if V043098 == 1

summarize econ2004
gen econ01 = (econ2004 - `r(min)') / (`r(max)'-`r(min)')
label var econ01 "Economic Eval"

*Candidate Traits*
label def trai 1 "Not Well at All" 4 "Extremely Well"
gen bush2004moral = .
replace bush2004moral = 1 if V043117 == 4
replace bush2004moral = 2 if V043117 == 3
replace bush2004moral = 3 if V043117 == 2
replace bush2004moral = 4 if V043117 == 1
gen bush2004knowl = . 
replace bush2004knowl = 1 if V043120 == 4
replace bush2004knowl = 2 if V043120 == 3
replace bush2004knowl = 3 if V043120 == 2
replace bush2004knowl = 4 if V043120 == 1
gen bush2004leader = . 
replace bush2004leader = 1 if V043118 == 4
replace bush2004leader = 2 if V043118 == 3
replace bush2004leader = 3 if V043118 == 2
replace bush2004leader = 4 if V043118 == 1


gen kerry2004moral = .
replace kerry2004moral = 1 if V043124 == 4
replace kerry2004moral = 2 if V043124 == 3
replace kerry2004moral = 3 if V043124 == 2
replace kerry2004moral = 4 if V043124 == 1
gen kerry2004knowl = . 
replace kerry2004knowl = 1 if V043127 == 4
replace kerry2004knowl = 2 if V043127 == 3
replace kerry2004knowl = 3 if V043127 == 2
replace kerry2004knowl = 4 if V043127 == 1
gen kerry2004leader = . 
replace kerry2004leader = 1 if V043125 == 4
replace kerry2004leader = 2 if V043125 == 3
replace kerry2004leader = 3 if V043125 == 2
replace kerry2004leader = 4 if V043125 == 1

label values kerry2004leader trai
label values kerry2004moral trai
label values kerry2004knowl trai
label values bush2004knowl trai
label values bush2004moral trai
label values bush2004leader trai



*Comparative Traits*
gen moral2004 = bush2004moral - kerry2004moral
gen knowl2004 = bush2004knowl - kerry2004knowl
gen leader2004 = bush2004leader - kerry2004leader



foreach var in  moral2004 knowl2004 leader2004 {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
